﻿/******************************************************************
 *Company: http://www.xiaomutech.com/
 *fileName : animationwidget.h --- AnimationWidget
 *Auth       : yhni (QQ:393320854)
 *Create    : 2022/2/12
 *Description   :
 *Histroy:
 *<Auth>    <Date>        <Ver>        <Content>
 *         2022/2/12
 *******************************************************************/
#ifndef ANIMATIONWIDGET_H
#define ANIMATIONWIDGET_H

#include <QWidget>
#include <QPropertyAnimation>
#include <QMovie>

class AnimationWidget : public QWidget
{
    Q_OBJECT
    Q_PROPERTY(QPoint imgpos READ imgPos WRITE setPoint)

public:
    explicit AnimationWidget(QWidget *parent = nullptr);
    ~AnimationWidget();

    typedef enum {None, LeftToRight, RightToLeft, BottomToTop, TopToBottom} Direction;

    void setSource(const QString &_img, AnimationWidget::Direction _direction = AnimationWidget::None);

    QPoint imgPos() const;
    void setPoint(const QPoint &_pos);

signals:

private slots:
    void frameChanged(int index);

private:
    QPropertyAnimation *m_animation;
    QPoint              m_imgPos;
    QMovie             *m_movie;
    QPixmap             m_pixmap;
    Direction           m_direction;

protected:
    void paintEvent(QPaintEvent *) override;
};

#endif // ANIMATIONWIDGET_H
